#ifndef __SI12_IIC_H
#define __SI12_IIC_H

#include "stm32f10x.h"
#include "sys.h"
#include "delay.h"


#define SI12_SCL_SET (GPIO_SetBits(GPIOB,GPIO_Pin_6))
#define SI12_SCL_RESET (GPIO_ResetBits(GPIOB,GPIO_Pin_6))


#define SI12_SDA_SET (GPIO_SetBits(GPIOB,GPIO_Pin_7))
#define SI12_SDA_RESET (GPIO_ResetBits(GPIOB,GPIO_Pin_7))


/* 读SDA口线状态 */
#define SI12TCH_I2C_SDA_READ()  (GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_7) != 0)	

#define SI12TCH_FLAG_TIMEOUT ((int)0xff)
#define SI12TCH_LONG_TIMEOUT ((int)(10 * SI12TCH_FLAG_TIMEOUT))
	
void si12tch_iic_sda(uint8_t mode);
void si12tch_i2c_Delay(void);	//延时
void si12tch_iic_Init(void);	//初始化
void si12tch_i2c_Start(void);	//发送IIC开始信号
void si12tch_i2c_Stop(void);	//发送IIC停止信号
unsigned char si12tch_i2c_WaitAck(void);		//IIC等待ACK信号
void si12tch_i2c_SendByte(unsigned char _ucByte); //IIC发送一个字节
unsigned char si12tch_i2c_ReadByte(uint8_t ack); 	//IIC读取一个字节
void si12tch_i2c_Ack(void);			//IIC发送ACK信号
void si12tch_i2c_NAck(void);	//IIC发送NAck信号

#endif // !__SI12_IIC_H
